//package com.shopoo.oauth.infrastructure.bloomfilter.service.impl;
//
//import javax.annotation.Resource;
//
//import com.bngrp.oauth2.infrastructure.bloomfilter.service.BloomFilterService;
//import com.bngrp.oauth2.infrastructure.bloomfilter.util.BloomFilterHelper;
//import com.google.common.base.Preconditions;
//
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.stereotype.Service;
//
///**
// * @Description:
// * @Auther: limy66
// * @Date: 2021/07/21/17:47
// */
//@Service
//public class BloomFilterServiceImpl implements BloomFilterService {
//
//    @Resource
//    private RedisTemplate redisTemplate;
//
//    @Override
//    public <T> void addByBloomFilter(BloomFilterHelper<T> bloomFilterHelper, String key, T value) {
//        Preconditions.checkArgument(bloomFilterHelper != null, "bloomFilterHelper不能为空");
//        int[] offset = bloomFilterHelper.murmurHashOffset(value);
//        for (int i : offset) {
//            redisTemplate.opsForValue().setBit(key, i, true);
//        }
//    }
//
//    @Override
//    public <T> boolean includeByBloomFilter(BloomFilterHelper<T> bloomFilterHelper, String key, T value) {
//        Preconditions.checkArgument(bloomFilterHelper != null, "bloomFilterHelper不能为空");
//        int[] offset = bloomFilterHelper.murmurHashOffset(value);
//        for (int i : offset) {
//            if (!redisTemplate.opsForValue().getBit(key, i)) {
//                return false;
//            }
//        }
//        return true;
//    }
//}
